Repository navigation
Fixes #31346: answer 401 without echoing the token when a Basic/LDAP refresh token is expired - #35034
Conversation
…refresh token is expired An expired refresh token threw CustomExceptionMessage(BAD_REQUEST) with the token UUID in its message, which /auth/refresh wrote to the client as a 400. An empty token was a 400 too. Both are rejected credentials: throw AuthenticationException with a fixed message so the servlet path and the /users/refresh resource answer 401 and the token never reaches the wire.
Code Review ✅ Approved🟡 Medium risk · Changing Basic/LDAP refresh failures from 400 to 401 could alter client reauthentication handling; expired credentials stay rejected and token UUIDs are no longer exposed. Basic and LDAP authenticators now throw OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 20m 16s |
Describe your changes:
Fixes #31346
With Basic or LDAP auth, an expired refresh token made
/api/v1/auth/refresh(and/api/v1/users/refresh) answer 400 with the token UUID in the body ("Expired token. Please login again : <uuid>"). An empty token was a 400 too. Both are rejected credentials, soBasicAuthenticatorandLdapAuthenticatornow throwAuthenticationExceptionwith a fixed message. The servlet failure handler (SecurityUtil.writeFailureResponse) and the JAX-RS mapper (CatalogGenericExceptionMapper) already turn that exception into a 401, so both endpoints answer 401 and the token never reaches the response.Earlier PRs fixed the other cases in the issue, and this PR doesn't change them:
Invalid credentials(Basic/LDAP, viawriteFailureResponse)The token UUID is no longer written to the server log either: a refresh token is a credential, and once it has expired it tells an operator nothing.
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
/api/v1/auth/refresh→ 401, and the body doesn't contain the token (the issue's own repro).Unit tests
SecurityUtilTest, and the behavior is covered end to end by the IT below.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.SessionMultiNodeIT#expiredRefreshTokenIsRejectedWithoutEchoingIt(MySQL and Postgres SQL)The run below was taken with this diff uncommitted on
9f52d6702fa2; the committed content is identical. The one failure,DomainIsolationIT#test_lineage_restrictedBotSeesOnlyOwnDomainNodes(Awaitility timed out after 1 minute waiting for the search index), passed when re-run alone with the same command. It's a lineage/domain-isolation test that doesn't touch refresh tokens, so I'm treating it as a flake (1 failure in 1 full run).Local Java test run: FAILED
9f52d6702fa2(baseorigin/main) — uncommitted changes were presentFailed:
DomainIsolationIT#test_lineage_restrictedBotSeesOnlyOwnDomainNodes(TestNamespace)Tests run locally
BasicAuthLoginServletTest(5 passed),BasicAuthServletHandlerTest(2 passed),LdapAuthServletHandlerTest(5 passed),LdapAuthenticatorTest(5 passed),LdapLookupConnectionPoolTest(3 passed),SecurityUtilTest(100 passed),TestLoginCredentialHandlerTest(7 passed)SessionMultiNodeIT(11 passed),UserMetricsResourceIT(7 passed)RdfFusekiAuthorizationIT(9 passed)SessionRedisMultiNodeIT(8 passed),TokenRevocationRedisMultiNodeIT(3 passed)Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The step totals above are Maven's own counts.
integration · mysql-elasticsearch · parallel: 36 classes
AIGovernancePolicyResourceIT(4 passed),AppOperationPermissionsIT(10 passed),BaseEntityIT$ListEntityHistoryByTimestampPaginationTest(33 passed, 3 skipped),BotImpersonationIT(1 passed),BotResourceIT(31 passed, 4 skipped),BulkOperationPermissionsIT(1 passed),ConfigResourceIT(12 passed),DataContractPermissionIT(11 passed, 5 skipped),DatabaseSmokeIT(1 passed),DomainIsolationIT(83 passed, 6 skipped),EmailFirstIdentityIT(5 passed, 1 skipped),FeedAccessAuthzIT(16 passed, 1 skipped),GlossaryTermRelationSettingsPermissionsIT(12 passed),GlossaryTermResourceIT(102 passed, 2 skipped),McpOAuthIT(19 passed),McpPermissionIT(2 passed),OAuth2TokenManagerIT(8 passed),PermissionsResourceIT(43 passed, 4 skipped),PipelineStatusAuthorizationIT(6 passed),PolicyResourceIT(223 passed, 35 skipped),QueryVisibilityPolicyIT(86 passed, 1 failed, 6 skipped),RoleResourceIT(185 passed, 32 skipped),SamlSecurityConfigIT(9 passed),SecurityServiceResourceIT(53 passed, 1 skipped),SeedDataPresenceIT(4 passed),ServiceAttributePolicyIT(91 passed, 7 skipped),TableResourceIT(164 passed, 6 skipped),TaskPermissionsIT(15 passed, 1 skipped),TestCaseCsvDomainIsolationIT(70 passed, 5 skipped),TestLoginSessionSweepIT(5 passed, 1 skipped),UserDefaultTeamAssignmentIT(1 passed),UserImportPrivilegeEscalationIT(53 passed, 5 skipped),UserPreferencesIT(6 passed, 1 skipped),UserResourceIT(188 passed, 21 skipped),UserTeamAssignmentPrivilegeIT(87 passed, 10 skipped),WorkflowTriggerPermissionsIT(15 passed)Why these tests
area security←openmetadata-service/src/main/java/org/openmetadata/service/security/auth/BasicAuthenticator.java,openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthenticator.javachanged test←openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SessionMultiNodeIT.javasmoke←code other than a test class changedImpacted, not run locally (2)
GoogleSsoSignInUIIT→ nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)GoogleSsoBootstrapUIIT→ nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)Commands
mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=BasicAuthLoginServletTest,BasicAuthServletHandlerTest,LdapAuthServletHandlerTest,LdapAuthenticatorTest,LdapLookupConnectionPoolTest,SecurityUtilTest,TestLoginCredentialHandlerTest -Dsurefire.failIfNoSpecifiedTests=false mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<35 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=SessionMultiNodeIT,UserMetricsResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf -Dit.test=RdfFusekiAuthorizationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=global-state -Dit.test=SessionRedisMultiNodeIT,TokenRevocationRedisMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falseIngestion integration tests
Playwright (UI) tests
Manual testing performed
Covered by the IT above, which reproduces the issue's steps against a live server.
UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code